﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DAL;

namespace Shop
{
    public partial class Form1 : Form,IView
    {
        public Form1()
        {
            InitializeComponent();
            cb_Categories.SelectedIndexChanged += (sender, args) => Invoke(SelectCategories);
            dgv_NamesOfProduct.SelectionChanged += (sender, args) => Invoke(SelectProduct);
            btn_Logout.MouseClick += (sender, args) => Invoke(Logout);
            btn_Login.MouseClick += (sender, args) => Invoke(Login);


        }
        public event Action SelectCategories;
        public event Action SelectProduct;
        public event Action Login;
        public event Action Logout;
        public event Action SetID;
        public event Action SetProduct;
        public event Action SetPrice;
        public event Action SetCategory;
        public event Action SetDescription;
        public event Action SetImage;

        private string userName;
        public string UserName
        {
            public get { return userName; }
            public set { userName = value; }
        }

        private string userPassword;
        public string UserPassword
        {
            public get { return userPassword; }
            public set { userPassword = value; }
        }



        public void ConnectionEstablisher(string userName, string userPassword)
        {

        }
        public void DataRefresh()
        {

        }
        public void Create()
        {

        }
        public void Return()
        {

        }
        public void Update()
        {

        }
        public void Delete()
        {

        }

        private void Invoke(Action action)
        {
            if (action != null) 
            {
                action();
            }
        }
        public new void Show()
        {
            Application.Run(this);
            //base.Show();
        }





        //private void cb_Categories_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (SelectCategories != null)
        //    {
        //        SelectCategories.Invoke(sender, e);
        //    }
        //}

        //private void dgv_NamesOfProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    if (SelectProduct != null)
        //    {
        //        SelectProduct.Invoke(sender, e);
        //    }
        //}

        //private void btn_Login_Click(object sender, EventArgs e)
        //{
        //    if (Login != null)
        //    {
        //        Login.Invoke(sender,e);
        //    }
        //}

        //private void btn_Logout_Click(object sender, EventArgs e)
        //{
        //    if(Logout != null)
        //    {
        //        Logout.Invoke(sender, e);
        //    }
        //}

        //private void pb_Picture_Click(object sender, EventArgs e)
        //{
        //    if (SetImage != null)
        //    {
        //        SetImage.Invoke(sender, e);
        //    }
        //}

    }
}
